package com.jsj.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.org.glassfish.gmbal.ParameterNames;


//@WebServlet("/HelloServlet3")
public class HelloServlet3 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public HelloServlet3() {
        super();
    }
    @Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
	String username=config.getInitParameter("username");
	String password=config.getInitParameter("password");
    System.out.println("username===="+username+"\tpassword=="+password);
}
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.getWriter().append("Served at: ").append(request.getContextPath());
		
		//设置响应到客户端的MIME类型及编码方式
		response.setContentType("text/html;charst=UTF-8");
		//使用ServletContext对象获取所有初始化参数
		Enumeration<String>paramNames = super.getServletContext().getInitParameterNames();
		//使用ServletContext对象获取某个初始化参数
		String sitename = super.getServletContext().getInitParameter("sitename");
		String per = super.getServletContext().getInitParameter("per");
		//获取输出流
		//输出响应结果
		while(paramNames.hasMoreElements()) {
			String name = paramNames.nextElement();
			System.out.println(name + "  ");
		}
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
